from django.db import models
from django.contrib.auth.models import User

# Create your models here.

'''
一个类等同于一个模型 
绑定到制定用户
'''

class Topic(models.Model):

	text = models.CharField(max_length=200)
	date_added = models.DateTimeField(auto_now_add=True)
	owner = models.ForeignKey(User)

	def __str__(self):
		return self.text



class Entry(models.Model):
	''' 学到的有关某个主题的知识点 '''
	topic = models.ForeignKey(Topic)
	text = models.TextField()
	date_added = models.DateTimeField(auto_now_add=True)

	class Meta:
		verbose_name_plural = 'entries'

	def __str__(self):
		''' 返回模型的字符串表示'''
		return self.text[:50] + '...'


